#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 25;

char g[N][N];
int n, m;
bool st[N][N];
int x, y;
int ans = 1;
int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

void dfs(int x, int y)
{
    if (g[x][y] == '.') {
        ans ++ ;
    }
    if (g[x][y] == '#') return ;
    st[x][y] = true;
    for (int i = 0; i < 4; i ++ )
    {
        int a = x + d[i][0], b = y + d[i][1];
        if (a < 0 || a >= n || b < 0 || b >= m) continue;
        if (st[a][b]) continue;
        dfs(a, b);
    }
}

int main()
{
    while (cin >> m >> n, n && m)
    {
        ans = 1;
        memset(st, 0, sizeof st);
        for (int i = 0; i < n; i ++ )
        {
            scanf("%s", g[i]);
            for (int j = 0; j < m; j ++ )
            if (g[i][j] == '@') x = i, y = j;
        }
        dfs(x, y);
        cout << ans << endl;
    }
    return 0;
}
